home *** CD-ROM | disk | FTP | other *** search
- //
- // Module name: as_proc.cod
- // Description: Procedure file for the generated application
- //
- *{replicate("-",79)}
- * Description..: Procedure files for generated menu system.
- * The programs that follow are common to main routines
- * The last procedure is the Menu Process DEFinition
- *{replicate("-",79)}
-
- PROCEDURE Lockit
- PARAMETER pc_ltype
- *{replicate("-",69)}
- * Lock the current file or record based on the value of <pc_ltype>.
- *{replicate("-",69)}
- IF NETWORK()
- gn_error=0
- ON ERROR DO Multerr
- IF pc_ltype = "1"
- ll_lock=FLOCK()
- ENDIF
- IF pc_ltype = "2"
- ll_lock=RLOCK()
- ENDIF
- ON ERROR
- ENDIF
- RETURN
- *-- EOP: Lockit WITH pc_ltype
-
- PROCEDURE Info_Box
- PARAMETERS pc_say
- *{replicate("-",69)}
- * Display the message <pc_say> inside of boxes.
- *{replicate("-",69)}
- ? pc_say
- ? REPLICATE("-",LEN(pc_say))
- ?
- RETURN
- *--EOP: Info_Box WITH pc_say
-
- PROCEDURE ShowPick
- *{replicate("-",69)}
- * Show pick list values.
- *{replicate("-",69)}
- PRIVATE ln_ikey, x1, x2
-
- listval=PROMPT()
- IF LEFT(entryflg,1)="B"
- lc_file=POPUP()
- DO &lc_file. WITH "A"
- RETURN
- ENDIF
- IF TYPE("lc_window")="U"
- ACTIVATE WINDOW ShowPick
- ELSE
- ACTIVATE WINDOW &lc_window.
- ENDIF
-
- STORE 0 TO ln_ikey,x1,x2
- ln_ikey=LASTKEY()
- IF ln_ikey=13
- x1=AT(TRIM(listval)+',',lc_fldlst)
- IF x1 = 0
- lc_fldlst=lc_fldlst+TRIM(listval)+','
- ELSE
- x2=AT(',',SUBSTR(lc_fldlst,x1))
- lc_fldlst=STUFF(lc_fldlst,x1,x2,'')
- ENDIF
- CLEAR
- ? lc_fldlst
- ENDIF
- ACTIVATE SCREEN
-
- RETURN
- *--EOP: ShowPick
-
- { include "as_clnup.cod";}
- { include "as_pause.cod";}
- { include "as_muser.cod";}
- { include "as_trce.cod";}
- { include "as_prin.cod";}
- { include "as_posit.cod";}
- PROCEDURE BefAct
- *{replicate("-",69)}
- * Save the screen before executing a menu option.
- *{replicate("-",69)}
- SAVE SCREEN TO Browscr&lc_ApGen.
- DEACTIVATE WINDOW Fullscr
- SET SCOREBOARD ON
- RETURN
- *--EOP: BefAct
-
- PROCEDURE AftAct
- *{replicate("-",69)}
- * Restore the screen after executing a menu option.
- *{replicate("-",69)}
- CLEAR
- SET SCOREBOARD OFF
- ACTIVATE WINDOW Fullscr
- RESTORE SCREEN FROM Browscr&lc_ApGen.
- RELEASE SCREEN Browscr&lc_ApGen.
- RETURN
- *--EOP: AftAct
-
- PROCEDURE Postnhlp
- *{replicate("-",69)}
- * Display help screens for generic menus.
- *{replicate("-",69)}
- DEFINE WINDOW Temphelp FROM 3,12 TO 19,67
- ACTIVATE WINDOW Temphelp
- DO CASE
- CASE "SEEK" $ PROMPT()
- *-- HELP SEEK
- ? " SEEK <exp>"
- ?
- ? " Evaluates a specified expression and attempts to"
- ? " find its value in the master index of the database"
- ? " file. Returns a logical true (.T.) if the index"
- ? " key is found, and a logical false (.F.) if it is"
- ? " not found."
- ?
- ? " Ex: SEEK CTOD('11/03/87') - converts the"
- ? " expression from character to date and"
- ? " then searches for the value in the index"
- ?
- CASE LEFT(LTRIM(PROMPT()),4) $ "GOTO TOP BOTT Reco"
- *-- HELP GOTO
- ? " GO/GOTO BOTTOM/TOP [IN <alias>]"
- ? " or"
- ? " GO/GOTO [RECORD] <record number> [IN <alias>]"
- ? " or"
- ? " <record number>"
- ?
- ? " Positions the record pointer to a specified record"
- ? " or location in the active database file."
- ?
- ? " TOP moves the pointer to the first record"
- ? " BOTTOM moves the pointer to the last record"
- ?
- ? " Ex: 4 - moves the record pointer to record 4"
- ?
- CASE "LOCATE" $ PROMPT()
- *-- HELP LOCATE
- ? " LOCATE FOR <condition> [<scope>]"
- ? " [WHILE <condition>]"
- ?
- ? " Searches the active database file, sequentially,"
- ? " for the first record that meets the specified"
- ? " criteria. The function FOUND() returns true (.T.)"
- ? " if LOCATE is successful."
- ?
- ? " Ex: LOCATE FOR Age = '25' NEXT 5"
- ? " searches for the next five records"
- ? " containing 25 in the Age field"
- ?
- CASE "Change index order" $ PROMPT() .OR. POPUP() = "SHOWTAG"
- ?
- ? [ Select "Change index order" to select the master]
- ? " (controlling) index. You will see a list of indexes"
- ? " from the stand-alone indexes (.ndx). and mdx"
- ? " file(s) that are activated. The first option in the"
- ? " list, NATURAL ORDER, uses the file in its unindexed"
- ? " state. Press RETURN to select your choice by which"
- ? " to order the file."
- ?
- ENDCASE
-
- DO Wait4Key
-
- DEACTIVATE WINDOW Temphelp
- RELEASE WINDOW Temphelp
- RETURN
- *--EOP: Postnhlp
-
- PROCEDURE Wait4Key
- *{replicate("-",69)}
- * Wait for a key press or mouse click.
- *{replicate("-",69)}
- PRIVATE ll_escape
-
- ll_escape = SET( "ESCAPE" ) = "ON"
- SET ESCAPE OFF
- WAIT
- IF ll_escape
- SET ESCAPE ON
- ENDIF
-
- RETURN
- *-- EOP: Wait4Key
-
- FUNCTION Color
- PARAMETERS pc_scolor
- *---------------------------------------------------------------------------
- * Format:
- * COLOR( <expC> )
- * <expC> = NORMAL, HIGHLIGHT, MESSAGES, TITLES, BOX, INFORMATION, FIELDS
- * or a variable with all colors store in it
- * Ver: dBASE 1.1
- *
- * The COLOR() function either returns or sets colors returned with the
- * SET("attribute") setting
- * If <expC> is a color string then null is returned otherwise the color
- * setting is returned for one of dBASE's color options
- *
- * See Also: SET("attribute")
- *
- *---------------------------------------------------------------------------
- PRIVATE color_num, color_str, cnt
-
- pc_scolor = UPPER(pc_scolor)
- IF pc_scolor = "COLOR"
- *- Return standard, enhanced, border colors only
- RETURN SUBSTR(SET("attr"),1, AT(" &", SET("attr")))
- ENDIF
-
- *- Declare array to parse color options from SET("attr")
- PRIVATE color_
- DECLARE color_[8]
- *- Determine if user is restoring colors vs. saving colors
- IF " &" $ pc_scolor
- color_str = ","+pc_scolor+"," && Restore color attributes
- ELSE
- color_str = ","+SET("ATTRIBUTE")+"," && Save color attributes
- ENDIF
-
- *-- Stuff array with individual color setting
- color_str = STUFF(color_str, AT(" &", color_str), 4, ",")
- cnt = 1
- DO WHILE cnt <= 8
- color_str = SUBSTR(color_str, AT(",", color_str ) +1 )
- color_[cnt] = SUBSTR(color_str, 1, AT(",", color_str ) - 1)
- cnt = cnt + 1
- ENDDO
-
- IF " &" $ pc_scolor
- *-- Set color back
- SET COLOR TO ,,&color_[3]. && Border color
- SET COLOR OF NORMAL TO &color_[1].
- SET COLOR OF HIGHLIGHT TO &color_[2].
- SET COLOR OF MESSAGES TO &color_[4].
- SET COLOR OF TITLES TO &color_[5].
- SET COLOR OF BOX TO &color_[6].
- SET COLOR OF INFORMATION TO &color_[7].
- SET COLOR OF FIELDS TO &color_[8].
- ELSE
- *-- Return color string requested
- DO CASE
- CASE pc_scolor $ "NORMAL"
- color_num = 1
- CASE pc_scolor $ "HIGHLIGHT"
- color_num = 2
- CASE pc_scolor $ "BORDER"
- color_num = 3
- CASE pc_scolor $ "MESSAGES"
- color_num = 4
- CASE pc_scolor $ "TITLES"
- color_num = 5
- CASE pc_scolor $ "BOX"
- color_num = 6
- CASE pc_scolor $ "INFORMATION"
- color_num = 7
- CASE pc_scolor $ "FIELDS"
- color_num = 8
- ENDCASE
- ENDIF
- RETURN IIF(" &" $ pc_scolor, "", color_[color_num])
-
- FUNCTION _NodShake
- PARAMETERS pc_mssg, pn_up, pn_left, pn_height, pn_max, pl_dflt_no
- *---------------------------------------------------------------------------
- * NAME
- * _NodShake
- *
- * DESCRIPTION
- * Accepts a YES/NO response from user
- *
- * SYNOPSIS
- * DO _NodShake WITH pc_mssg, pn_up, pn_left, pn_height, pn_max, pl_dflt_no
- *
- * PARAMETERS
- * pc_mssg: dialog box message
- * pn_up: upper corrdinate of dialog box
- * pn_left: left coordinate of dialog box
- * pn_height: height of dialog box
- * pn_max: maximum width of a line in message
- * pl_dflt_no: flag indicating if default pad highlighted should be "NO"
- *
- * EXAMPLE
- * pl_set = _NodShake( pc_vermssg, 13, 25, 2, 28, .T. )
- *---------------------------------------------------------------------------
-
- PRIVATE ll_ans, ll_console, ll_wrapset, ln_pspset
-
- ll_console = SET( "CONSOLE" ) = "OFF"
- SET CONSOLE ON
- ll_wrapset = _wrap
- ln_pspset = _pspacing
- _wrap = .F.
- _pspacing = 1
-
- DEFINE WINDOW NodShake DOUBLE ;
- FROM pn_up, pn_left TO pn_up + pn_height + 4, pn_left + pn_max + 1
-
- DEFINE MENU NodShake
- DEFINE PAD Yes OF NodShake PROMPT "Yes" ;
- AT pn_height + 1, (pn_max - 12) / 2;
- MESSAGE "Select option and press ENTER, or press first letter" + ;
- " of desired option"
-
- ON SELECTION PAD Yes OF NodShake DEACTIVATE MENU
- DEFINE PAD No OF NodShake PROMPT "No" ;
- AT pn_height + 1, (pn_max - 12) / 2 + 10 ;
- MESSAGE "Select option and press ENTER, or press first letter" + ;
- " of desired option"
-
- ON SELECTION PAD No OF NodShake DEACTIVATE MENU
- ACTIVATE WINDOW NodShake
- CLEAR
- ?
- @ 0, 0
- ?? pc_mssg FUNCTION ";"
-
- ON KEY LABEL Y KEYBOARD "\{Alt-Y}\{13}"
- ON KEY LABEL N KEYBOARD "\{Alt-N}\{13}"
-
- IF pl_dflt_no
- KEYBOARD "\{Alt-N}"
- ENDIF
-
- ON KEY LABEL RIGHTARROW
- ON KEY LABEL LEFTARROW
-
- ACTIVATE MENU NodShake
-
- ON KEY LABEL Y
- ON KEY LABEL N
-
- IF PAD() = "YES"
- ll_ans = .T.
- ELSE
- ll_ans = .F.
- ENDIF
-
- RELEASE WINDOW NodShake
- RELEASE MENU NodShake
- _wrap = ll_wrapset
- _pspacing = ln_pspset
-
- IF ll_console
- SET CONSOLE OFF
- ENDIF
-
- RETURN ll_ans
- *-- EOF: _NodShake( pc_mssg, pn_up, pn_left, pn_height, pn_max, pl_dflt_no )
-
-
- PROCEDURE _Err_Box
- PARAMETERS pc_msg
- *----------------------------------------------------------------------------
- * NAME
- * _Err_Box - Display an error box
- *
- * SYNOPSIS
- * DO _Err_Box WITH <pc_msg>
- *
- * DESCRIPTION
- * _Err_Box will display the <pc_msg> string in a box and prompt the
- * user to press any key to continue processing. _Err_Box will display
- * the message based on the length of <pc_msg>.
- *
- * PARAMETERS
- * pc_msg - the error message to display in the box. If the length is
- * greater than 76, the trailing part is chopped off.
- *
- * EXAMPLE
- * DO _Err_Box WITH "Incorrect window size"
- * Displays the message in a window as follows at row 9 on the screen:
- * +------------------------------+
- * | |
- * | Incorrect window size |
- * | |
- * | Press any key to continue... |
- * | |
- * +------------------------------+
- * Note that the width of the window will increase to accommodate a longer
- * message string.
- *
- * LIMITATIONS
- * Truncates the message after 76 characters. Assumes an 80 character
- * wide screen. Looks best with SET CURSOR OFF.
- *
- *----------------------------------------------------------------------------
-
- PRIVATE lc_anykey, lc_msg, lc_msglen, lc_win, ln_press, ln_width, ll_trap,;
- ll_escape
-
- lc_anykey = [Press any key to continue...]
- ln_press = LEN( lc_anykey )
- lc_win = WINDOW() && Currently activated window if any
- lc_msg = LTRIM( RTRIM( pc_msg ) ) && Trimmed message
- ln_msglen = LEN( lc_msg ) && Trimmed length of message
- ln_width = 0 && Width of display area in window.
- ll_escape = SET("ESCAPE") = "ON"
- SET ESCAPE OFF
-
- *-- Determine the width needed for the window:
- IF ln_msglen <= ln_press
- ln_width = ln_press
- ELSE
- *-- Make sure the message fits in the window:
- IF ln_msglen > 76
- lc_msg = LEFT( lc_msg, 76 )
- ln_msglen = 76
- ENDIF
- ln_width = ln_msglen
- ENDIF
- DEFINE WINDOW _err_box FROM 9, ((76 - ln_width) + .5) / 2 ;
- TO 15, (ln_width + 83) / 2 DOUBLE
- ln_width = ( ln_width + 2 )
-
- *-- Display the message and prompt to the window and wait for a key press
- ACTIVATE WINDOW _err_box
- @ 1, ( ln_width - ln_msglen ) / 2 SAY lc_msg
- @ 3, ( ln_width - ln_press ) / 2 SAY lc_anykey
- SET CONSOLE OFF && For mouse click recognition
- WAIT
- SET CONSOLE ON
-
- *-- Clean up the window display and reactivate the previous window
- RELEASE WINDOW _err_box
- IF ISBLANK( lc_win )
- ACTIVATE SCREEN
- ENDIF
-
- IF ll_escape
- SET ESCAPE ON
- ELSE
- SET ESCAPE OFF
- ENDIF
-
- RETURN
- *-- EOP: _Err_Box WITH pc_msg
-
-
- // EOP AS_PROC.COD
-